package create.singleton.singleton_demo1;

/**
 * 登记式/静态内部类
 * 具有饿汉式优点，此外加载类的时候不会实例化
 *
 * @author yeyangtao
 * @date 2020/5/19 17:38
 */
public class Single5 {
    private String name;
    private Integer age;

    private static class SingleHolder{
        private static final Single5 INSTANCE = new Single5();
    }


    private Single5() {
    }

    public static Single5 getInstance() {
        return SingleHolder.INSTANCE;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
